home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 October: Mac OS SDK / Dev.CD Oct 97 SDK1.toast / Development Kits (Disc 1) / Interfaces&Libraries / Universal / Interfaces / AIncludes / TextUtils.a < prev    next >
Encoding:
Text File  |  1997-08-12  |  11.8 KB  |  431 lines  |  [TEXT/MPS ]

  1. ;
  2. ;    File:        TextUtils.a
  3. ;
  4. ;    Contains:    Text Utilities Interfaces.
  5. ;
  6. ;    Version:    Technology:    System 7.5
  7. ;                Release:    Universal Interfaces 3.0.1
  8. ;
  9. ;    Copyright:    © 1985-1997 by Apple Computer, Inc., all rights reserved.
  10. ;
  11. ;    Bugs?:        Please include the the file and version information (from above) with
  12. ;                the problem description.  Developers belonging to one of the Apple
  13. ;                developer programs can submit bug reports to:
  14. ;
  15. ;                    devsupport@apple.com
  16. ;
  17. ;
  18.     IF &TYPE('__TEXTUTILS__') = 'UNDEFINED' THEN
  19. __TEXTUTILS__ SET 1
  20.  
  21.     IF &TYPE('__TYPES__') = 'UNDEFINED' THEN
  22.     include 'Types.a'
  23.     ENDIF
  24.     IF &TYPE('__NUMBERFORMATTING__') = 'UNDEFINED' THEN
  25.     include 'NumberFormatting.a'
  26.     ENDIF
  27.     IF &TYPE('__STRINGCOMPARE__') = 'UNDEFINED' THEN
  28.     include 'StringCompare.a'
  29.     ENDIF
  30.     IF &TYPE('__DATETIMEUTILS__') = 'UNDEFINED' THEN
  31.     include 'DateTimeUtils.a'
  32.     ENDIF
  33.  
  34. ;
  35. ;    Here are the current System 7 routine names and the translations to the older forms.
  36. ;    Please use the newer forms in all new code and migrate the older names out of existing
  37. ;    code as maintainance permits.
  38. ;    
  39. ;    NEW NAME                    OLD NAMEs                    OBSOLETE FORM (no script code)
  40. ;
  41. ;    FindScriptRun
  42. ;    FindWordBreaks                                            NFindWord, FindWord
  43. ;    GetIndString            
  44. ;    GetString
  45. ;    Munger
  46. ;    NewString                
  47. ;    SetString                
  48. ;    StyledLineBreak
  49. ;    TruncString
  50. ;    TruncText
  51. ;
  52. ;    UpperString ($A054)            UprString, UprText
  53. ;    UppercaseText                SCUpperText (a only)        UpperText ($A456)
  54. ;    LowercaseText                                            LwrString, LowerText, LwrText ($A056)
  55. ;    StripDiacritics                                            StripText ($A256)
  56. ;    UppercaseStripDiacritics                                StripUpperText ($A656)
  57. ;
  58. ;
  59. ;
  60.  
  61.  
  62. ;  Type for truncWhere parameter in TruncString, TruncText 
  63. ; typedef short                         TruncCode
  64.  
  65.  
  66.                                                             ; Constants for truncWhere argument in TruncString and TruncText 
  67. truncEnd                        EQU        0                    ; Truncate at end 
  68. truncMiddle                        EQU        $4000                ; Truncate in middle 
  69. smTruncEnd                        EQU        0                    ; Truncate at end - obsolete 
  70. smTruncMiddle                    EQU        $4000                ; Truncate in middle - obsolete 
  71.  
  72.                                                             ; Constants for TruncString and TruncText results 
  73. notTruncated                    EQU        0                    ; No truncation was necessary 
  74. truncated                        EQU        1                    ; Truncation performed 
  75. truncErr                        EQU        -1                    ; General error 
  76. smNotTruncated                    EQU        0                    ; No truncation was necessary - obsolete 
  77. smTruncated                        EQU        1                    ; Truncation performed    - obsolete 
  78. smTruncErr                        EQU        -1                    ; General error - obsolete 
  79. ; typedef SInt8                         StyledLineBreakCode
  80.  
  81.  
  82. smBreakWord                        EQU        0
  83. smBreakChar                        EQU        1
  84. smBreakOverflow                    EQU        2
  85. ScriptRunStatus            RECORD 0
  86. script                     ds.b    1                ; offset: $0 (0)
  87. runVariant                 ds.b    1                ; offset: $1 (1)
  88. sizeof                     EQU *                    ; size:   $2 (2)
  89.                         ENDR
  90. BreakTable                RECORD 0
  91. charTypes                 ds.b    256                ; offset: $0 (0)
  92. tripleLength             ds.w    1                ; offset: $100 (256)
  93. triples                     ds.w    1                ; offset: $102 (258) <-- really an array of length one
  94. sizeof                     EQU *                    ; size:   $104 (260)
  95.                         ENDR
  96. ; typedef struct BreakTable *            BreakTablePtr
  97.  
  98. NBreakTable                RECORD 0
  99. flags1                     ds.b    1                ; offset: $0 (0)
  100. flags2                     ds.b    1                ; offset: $1 (1)
  101. version                     ds.w    1                ; offset: $2 (2)
  102. classTableOff             ds.w    1                ; offset: $4 (4)
  103. auxCTableOff             ds.w    1                ; offset: $6 (6)
  104. backwdTableOff             ds.w    1                ; offset: $8 (8)
  105. forwdTableOff             ds.w    1                ; offset: $A (10)
  106. doBackup                 ds.w    1                ; offset: $C (12)
  107. length                     ds.w    1                ; offset: $E (14)        ;  length of NBreakTable 
  108. charTypes                 ds.b    256                ; offset: $10 (16)
  109. tables                     ds.w    1                ; offset: $110 (272) <-- really an array of length one
  110. sizeof                     EQU *                    ; size:   $112 (274)
  111.                         ENDR
  112. ; typedef struct NBreakTable *            NBreakTablePtr
  113.  
  114. ;  The following functions are new names that work on 68k and PowerPC
  115. ;
  116. ; pascal long Munger(Handle h, long offset, const void *ptr1, long len1, const void *ptr2, long len2)
  117. ;
  118.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  119.         _Munger:    OPWORD    $A9E0
  120.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  121.         IMPORT_CFM_FUNCTION Munger
  122.     ENDIF
  123.  
  124. ;
  125. ; pascal StringHandle NewString(ConstStr255Param theString)
  126. ;
  127.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  128.         _NewString:    OPWORD    $A906
  129.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  130.         IMPORT_CFM_FUNCTION NewString
  131.     ENDIF
  132.  
  133. ;
  134. ; pascal void SetString(StringHandle theString, ConstStr255Param strNew)
  135. ;
  136.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  137.         _SetString:    OPWORD    $A907
  138.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  139.         IMPORT_CFM_FUNCTION SetString
  140.     ENDIF
  141.  
  142. ;
  143. ; pascal StringHandle GetString(short stringID)
  144. ;
  145.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  146.         _GetString:    OPWORD    $A9BA
  147.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  148.         IMPORT_CFM_FUNCTION GetString
  149.     ENDIF
  150.  
  151. ;
  152. ; pascal StyledLineBreakCode StyledLineBreak(Ptr textPtr, long textLen, long textStart, long textEnd, long flags, Fixed *textWidth, long *textOffset)
  153. ;
  154.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  155.         Macro
  156.         _StyledLineBreak
  157.             move.l              #$821CFFFE,-(sp)
  158.             dc.w                $A8B5
  159.         EndM
  160.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  161.         IMPORT_CFM_FUNCTION StyledLineBreak
  162.     ENDIF
  163.  
  164. ;
  165. ; pascal short TruncString(short width, Str255 theString, TruncCode truncWhere)
  166. ;
  167.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  168.         Macro
  169.         _TruncString
  170.             move.l              #$8208FFE0,-(sp)
  171.             dc.w                $A8B5
  172.         EndM
  173.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  174.         IMPORT_CFM_FUNCTION TruncString
  175.     ENDIF
  176.  
  177. ;
  178. ; pascal short TruncText(short width, Ptr textPtr, short *length, TruncCode truncWhere)
  179. ;
  180.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  181.         Macro
  182.         _TruncText
  183.             move.l              #$820CFFDE,-(sp)
  184.             dc.w                $A8B5
  185.         EndM
  186.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  187.         IMPORT_CFM_FUNCTION TruncText
  188.     ENDIF
  189.  
  190. ;
  191. ; pascal void FindWordBreaks(Ptr textPtr, short textLength, short offset, Boolean leadingEdge, BreakTablePtr breaks, OffsetTable offsets, ScriptCode script)
  192. ;
  193.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  194.         Macro
  195.         _FindWordBreaks
  196.             move.l              #$C012001A,-(sp)
  197.             dc.w                $A8B5
  198.         EndM
  199.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  200.         IMPORT_CFM_FUNCTION FindWordBreaks
  201.     ENDIF
  202.  
  203. ;
  204. ; pascal void LowercaseText(Ptr textPtr, short len, ScriptCode script)
  205. ;
  206.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  207.         Macro
  208.         _LowercaseText
  209.             move.w              #$0000,-(sp)
  210.             move.l              #$800AFFB6,-(sp)
  211.             dc.w                $A8B5
  212.         EndM
  213.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  214.         IMPORT_CFM_FUNCTION LowercaseText
  215.     ENDIF
  216.  
  217. ;
  218. ; pascal void UppercaseText(Ptr textPtr, short len, ScriptCode script)
  219. ;
  220.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  221.         Macro
  222.         _UppercaseText
  223.             move.w              #$0400,-(sp)
  224.             move.l              #$800AFFB6,-(sp)
  225.             dc.w                $A8B5
  226.         EndM
  227.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  228.         IMPORT_CFM_FUNCTION UppercaseText
  229.     ENDIF
  230.  
  231. ;
  232. ; pascal void StripDiacritics(Ptr textPtr, short len, ScriptCode script)
  233. ;
  234.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  235.         Macro
  236.         _StripDiacritics
  237.             move.w              #$0200,-(sp)
  238.             move.l              #$800AFFB6,-(sp)
  239.             dc.w                $A8B5
  240.         EndM
  241.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  242.         IMPORT_CFM_FUNCTION StripDiacritics
  243.     ENDIF
  244.  
  245. ;
  246. ; pascal void UppercaseStripDiacritics(Ptr textPtr, short len, ScriptCode script)
  247. ;
  248.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  249.         Macro
  250.         _UppercaseStripDiacritics
  251.             move.w              #$0600,-(sp)
  252.             move.l              #$800AFFB6,-(sp)
  253.             dc.w                $A8B5
  254.         EndM
  255.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  256.         IMPORT_CFM_FUNCTION UppercaseStripDiacritics
  257.     ENDIF
  258.  
  259. ;
  260. ; pascal ScriptRunStatus FindScriptRun(Ptr textPtr, long textLen, long *lenUsed)
  261. ;
  262.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  263.         Macro
  264.         _FindScriptRun
  265.             move.l              #$820C0026,-(sp)
  266.             dc.w                $A8B5
  267.         EndM
  268.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  269.         IMPORT_CFM_FUNCTION FindScriptRun
  270.     ENDIF
  271.  
  272.  
  273. ;      The following functions are old names, but are required for PowerPC builds
  274. ;      because InterfaceLib exports these names, instead of the new ones.
  275.  
  276.  
  277.  
  278. ;
  279. ; pascal void FindWord(Ptr textPtr, short textLength, short offset, Boolean leadingEdge, BreakTablePtr breaks, OffsetTable offsets)
  280. ;
  281.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  282.         Macro
  283.         _FindWord
  284.             move.l              #$8012001A,-(sp)
  285.             dc.w                $A8B5
  286.         EndM
  287.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  288.         IMPORT_CFM_FUNCTION FindWord
  289.     ENDIF
  290.  
  291. ;
  292. ; pascal void NFindWord(Ptr textPtr, short textLength, short offset, Boolean leadingEdge, NBreakTablePtr nbreaks, OffsetTable offsets)
  293. ;
  294.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  295.         Macro
  296.         _NFindWord
  297.             move.l              #$8012FFE2,-(sp)
  298.             dc.w                $A8B5
  299.         EndM
  300.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  301.         IMPORT_CFM_FUNCTION NFindWord
  302.     ENDIF
  303.  
  304.  
  305. ;   On 68K machines, LwrText, LowerText, StripText, UpperText and StripUpperText
  306. ;   return an error code in register D0, but System 7 PowerMacs do not emulate
  307. ;   this properly, so checking D0 is unreliable.
  308.  
  309.  
  310.  
  311. ;
  312. ; pascal void LwrText(Ptr textPtr, short len)
  313. ;
  314.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  315.         ; parameters:
  316.         ;    textPtr         => A0
  317.         ;    len             => D0
  318.         _LwrText:    OPWORD    $A056
  319.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  320.         IMPORT_CFM_FUNCTION LwrText
  321.     ENDIF
  322.  
  323. ;
  324. ; pascal void LowerText(Ptr textPtr, short len)
  325. ;
  326.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  327.         ; parameters:
  328.         ;    textPtr         => A0
  329.         ;    len             => D0
  330.         _LowerText:    OPWORD    $A056
  331.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  332.         IMPORT_CFM_FUNCTION LowerText
  333.     ENDIF
  334.  
  335. ;
  336. ; pascal void StripText(Ptr textPtr, short len)
  337. ;
  338.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  339.         ; parameters:
  340.         ;    textPtr         => A0
  341.         ;    len             => D0
  342.         _StripText:    OPWORD    $A256
  343.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  344.         IMPORT_CFM_FUNCTION StripText
  345.     ENDIF
  346.  
  347. ;
  348. ; pascal void UpperText(Ptr textPtr, short len)
  349. ;
  350.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  351.         ; parameters:
  352.         ;    textPtr         => A0
  353.         ;    len             => D0
  354.         _UpperText:    OPWORD    $A456
  355.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  356.         IMPORT_CFM_FUNCTION UpperText
  357.     ENDIF
  358.  
  359. ;
  360. ; pascal void StripUpperText(Ptr textPtr, short len)
  361. ;
  362.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  363.         ; parameters:
  364.         ;    textPtr         => A0
  365.         ;    len             => D0
  366.         _StripUpperText:    OPWORD    $A656
  367.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  368.         IMPORT_CFM_FUNCTION StripUpperText
  369.     ENDIF
  370.  
  371.  
  372. ;  The following are new names which are exported by InterfaceLib
  373.  
  374.     IF TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  375. ;
  376. ; extern void UpperString(BytePtr textPtr, UInt16 length)
  377. ;
  378.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  379.         ; parameters:
  380.         ;    textPtr         => A0
  381.         ;    length          => D0
  382.         _UpperString:    OPWORD    $A054
  383.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  384.         IMPORT_CFM_FUNCTION UpperString
  385.     ENDIF
  386.  
  387. ;
  388. ; extern void UpperStringMarks(BytePtr textPtr, UInt16 length)
  389. ;
  390.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  391.         ; parameters:
  392.         ;    textPtr         => A0
  393.         ;    length          => D0
  394.         _UpperStringMarks:    OPWORD    $A254
  395.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  396.         IMPORT_CFM_FUNCTION UpperStringMarks
  397.     ENDIF
  398.  
  399.     ELSE
  400. ;
  401. ; pascal void UpperString(Str255 theString, Boolean diacSensitive)
  402. ;
  403.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  404.         IMPORT_CFM_FUNCTION UpperString
  405.     ENDIF
  406.  
  407.     ENDIF
  408. ;  Old routine name but no new names are mapped to it:
  409. ;
  410. ; pascal void UprText(Ptr textPtr, short len)
  411. ;
  412.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  413.         ; parameters:
  414.         ;    textPtr         => A0
  415.         ;    len             => D0
  416.         _UprText:    OPWORD    $A054
  417.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  418.         IMPORT_CFM_FUNCTION UprText
  419.     ENDIF
  420.  
  421. ;
  422. ;    Functions for converting between C and Pascal Strings
  423. ;    (Previously in Strings.h)
  424. ;    
  425. ;
  426.  
  427.     ENDIF ; __TEXTUTILS__ 
  428.  
  429.